from django.db import models


# Create your models here.
class Manufacturer(models.Model):
    vendor_name = models.CharField(verbose_name='厂商名称', help_text='设备厂商名称', max_length=32, db_index=True, unique=True)
    tel = models.CharField(verbose_name='联系电话', null=True, max_length=11, help_text='厂商联系电话')
    mail = models.EmailField(verbose_name='联系邮件', null=True, help_text='厂商联系邮件')
    remark = models.CharField(verbose_name='备注', null=True, max_length=256, help_text='厂商备注')
    ctime = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.vendor_name

    class Meta:
        db_table = 'manufacturer'
        ordering = ['id']
        verbose_name_plural = verbose_name = '服务器厂商信息'


class ProductModel(models.Model):
    model_name = models.CharField(verbose_name='设备型号', max_length=64, help_text='设备型号，尽量具体')
    vendor = models.ForeignKey(to=Manufacturer, verbose_name='制造厂商', help_text='设备制造厂商')
    ctime = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.model_name

    class Meta:
        db_table = 'productmodel'
        ordering = ['id', '-ctime']
        verbose_name_plural = verbose_name = '服务器型号信息'
